package com.itheima.utils;

import java.text.MessageFormat;
import java.util.Arrays;
import java.util.List;
import java.util.Map;

/**
 * ClassName:MyProvider
 * Package:com.itheima.utils
 * Description:
 * Date:2021/11/6 3:19
 * Author:liu.min
 */
public class MyProvider {
    public static String batchInsert(Long id, Long[] roleIds){
        StringBuilder sb = new StringBuilder();
        sb.append("insert into sys_user_role");
        sb.append(" values ");
        List<Long> longs = Arrays.asList(roleIds);
        int length = longs.size();
        longs.get(1);
        for(int i=0;i<length;i++){
            sb.append("("+id+","+longs.get(i)+")");
            if (i < length - 1) {
                sb.append(",");
            }
        }

        return sb.toString();
    }

    public static void main(String[] args) {
        Long[] roleIds = {1l,2l,3l,1l,4l};
        String s = batchInsert(1l, roleIds);
        System.out.println(s);
    }
}
